{extend name="Layout/datagrid" /}
{block name="content_header"}        
<h1>
    结算申请
    <small>advanced tables</small>
</h1>
<ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">结算申请</a></li>
    <li class="active">结算申请</li>
</ol>
{/block}
{block name="content"}
<div class="box">
    <!-- /.box-header -->
    <div class="box-body">
        <div class="row">
            <div class="col-md-6">
                <!-- form start -->
                <form action="{:url('doWithdraw')}" method="post" class="form-horizontal" style='margin-top:20px;'>
                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">可提现金额</label>
                            <div class="col-sm-9 form-control-static">
                                <strong style="color:#F00; font-size:16px">{$blance}</strong> 元
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">提现方式</label>
                            <div class="col-sm-9 input-group">
                                <select name="bankcardid" class="form-control" required="required">
                                    <option value="">====选择提现方式====</option>
                                    {foreach name="$banklist" item="vo"}
                                    <option value="{$vo.id}">{$vo.title}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">提现金额</label>
                            <div class="col-sm-9 input-group">
                                <input type="number" name="amount" class="form-control input-sm" data-blance="{$blance}" placeholder="提现金额" required="required" />
                                <span class="input-group-addon" id="basic-addon1">元</span>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <a class="btn btn-info" href="{:url('bankcardinfo')}">编辑银行卡资料</a>
                        <a class="btn btn-default" href="{:url('withdrawlist')}">提现记录</a>
                        {if($blance<1)}
                        <button type="button" class="btn btn-danger pull-right" disabled="disabled">余额不足，无法提现</button>
                        {else/}
                        <button type="submit" class="btn btn-primary pull-right">申请提现</button>
                        {/if}
                    </div>
                    <!-- /.box-footer -->
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="body_foot"}
<script>
    $('form').submit(function(){
        var amount=$('[name="amount"]').val();
        var blance=$('[name="amount"]').data('blance');
        if(!amount || isNaN(amount)){
            alert('金额无效!');
            return false;
        }
        if(blance<1){
            alert('余额不足!');
            return false;
        }
        if(amount>blance){
            alert('提现金额不能超过余额!');
            return false;
        }
        return true;
    })
</script>
{/block}